loadSharedData();
var currencyDecimalPlaces = 0;
var SharedData = {};
function loadSharedData(callback)
{
	var services = [];
	services.push(["/popupService",{doClass : "loadGeneral"},function(data,args) { SharedData.General = JSON.parse(data);},null]);
	services.push(["/popupService",{doClass:"loadSalutation"},function(data,args) { SharedData.Salutation = JSON.parse(data);},null]);
	arrayservice(services,LoadSharedServiceSuccess,callback);
}
function loadSharedDataIfNotExist(e,t,n){var r=[];for(var i=0;i<e.length;i++)if(SharedData[e[i][2]]==null){var s=e[i][2];e[i][2]=function(e,t){SharedData[t]=JSON.parse(e)};e[i][3]=s;r.push(e[i])}if(r.length!=0)arrayservice(r,t,n);else t(n)}
function LoadSharedServiceSuccess(callback)
{
	currencyDecimalPlaces = SharedData.General.currencyDecimalPlaces;
	dateFormatString = SharedData.General.dateFormat.dateTimeFormat;
}

function yearselectDropdown(dom)
{
	var date = new Date();
	date.getFullYear();
	for(var hi=1930; hi<=date.getFullYear(); hi++) 
	dom.append("<option value=\""+hi+"\">"+hi+"</option>");
}

function monthselectDropdown(dom)
{
	var month = [Month_Short_Jan,Month_Short_Feb,Month_Short_Mar,
			Month_Short_Apr,Month_Short_May,Month_Short_Jun,
			Month_Short_Jul,Month_Short_Aug,Month_Short_Sep,
			Month_Short_Oct,Month_Short_Nov,Month_Short_Dec
		];
	for(var hi=0; hi<month.length; hi++) 
dom.append("<option value=\""+hi+"\">"+month[hi]+"</option>");
}

function generaldayoption(dom){
	var dayamount = daysinmonth(dom.parent().find("[id*=month]").val());
	for(var i = 1;i <= dayamount ;i++){
		dom.append($("<option>").val((i)).html((i)));
	}
}

function checkoptiondate(dom){
	var monthselect = dom.val();
	var dayselect = dom.val(); 
	var daynowsize = dom.size();
	var daynewsize = daysinmonth(monthselect);
	if(daynowsize != daynewsize){
		dom.parent().find("[id*=date] option").remove();
		generaldayoption(dom.parent().find("[id*=date]"));
	}
}

function daysinmonth(num){
	if(parseInt(num) == 0 || parseInt(num) == 2 || parseInt(num) == 4 || parseInt(num) == 6 ||
			parseInt(num) == 7 || parseInt(num) == 9 || parseInt(num) == 11 ){
		return 31;
	}else if(parseInt(num) == 3 || parseInt(num) == 5 || parseInt(num) == 8 || 
			parseInt(num) == 10){
		return 30;
	}else if(parseInt(num) == 1 ){
		return 28;
	}
}

function genderDropdown(dom){
	var Array  = JSON.parse('[{"genderValue":"M","genText":"male"},{"genderValue":"F","genText":"female"}]');
	fillDropdown(dom,Array,"genderValue","genText");
}